---
title: Progress Bar
description: Progress bar show either determinate or indeterminate progress of an operation over time.
links:
  - label: Aria docs
    href: https://react-spectrum.adobe.com/react-aria/ProgressBar.html
  - label: Report an issue
    href: https://github.com/mehdibha/dotUI/issues/new/choose
  - label: Edit this page
    href: https://github.com/mehdibha/dotUI/tree/main/content/components/feedback/progress.mdx?plain=1
---

<ComponentPreview
  name="progress-bar/demos/default"
  preview={`<ProgressBar value={75} />`}
/>

## Installation

```package-install
npx shadcn@latest add @dotui/progress-bar
```

## Anatomy

```tsx
import { ProgressBar } from "@/components/core/progress-bar";

<ProgressBar value={30} />;
```

```tsx
import { Label } from "@/components/core/field";
import {
  ProgressBarIndicator,
  ProgressBarRoot,
  ProgressBarValueLabel,
} from "@/components/core/progress-bar";

<ProgressBarRoot value={30}>
  <div className="flex items-center justify-between gap-2">
    <Label>Progress</Label>
    <ProgressBarValueLabel />
  </div>
  <ProgressBarIndicator />
</ProgressBarRoot>;
```

## Visual options

### Variant

Use the `variant` prop to control the visual style of the `Progress`. The default variant is `"default"`.

<ComponentPreview
  name="progress-bar/demos/variants"
  preview={`<ProgressBar variant="primary" />
<ProgressBar variant="success" />
<ProgressBar variant="accent" />
<ProgressBar variant="danger" />
<ProgressBar variant="warning" />`}
/>

### Size

Use the `size` prop to control the size of the `Progress`. The default variant is `"md"`.

<ComponentPreview
  name="progress-bar/demos/sizes"
  preview={`<ProgressBar size="sm" />
<ProgressBar size="md" />
<ProgressBar size="lg" />`}
/>

## Labelling

### Label

A visual label can be provided using the `label` prop, or a hidden label using `aria-label` prop.

<ComponentPreview
  name="progress-bar/demos/label"
  preview={`<ProgressBar aria-label="loading" />
<ProgressBar label="loading..." />`}
/>

### Value label

Set the `showValueLabel` prop to `true` to display the current value of the progress bar.

<ComponentPreview
  name="progress-bar/demos/value-label"
  preview={`<ProgressBar label="Loading" showValueLabel value={75} />`}
/>

### Format options

Values are formatted as a percentage by default, but this can be modified by using the `formatOptions` prop to specify a different format.

<ComponentPreview
  name="progress-bar/demos/format-options"
  preview={`<Progress
    label="Sending…"
    showValueLabel
    formatOptions={{ style: "currency", currency: "JPY" }}
    value={60}
  />`}
/>

### Custom value label

The `valueLabel` prop allows the formatted value to be replaced with a custom string.

<ComponentPreview
  name="progress-bar/demos/custom-value-label"
  preview={`<Progress
    label="Feeding…"
    showValueLabel
    valueLabel="30 of 100 dogs"
    value={30}
  />`}
/>

## Value

### Value scale

A custom value scale can be used by setting the `minValue` and `maxValue` props.

<ComponentPreview
  name="progress-bar/demos/min-max-values"
  preview={`<Progress
    aria-label="Min and max values"
    minValue={50}
    maxValue={150}
    value={100}
  />`}
/>

### Indeterminate

The `isIndeterminate` prop can be used to represent an interdeterminate operation.

<ComponentPreview
  name="progress-bar/demos/indeterminate"
  preview={`<ProgressBar isIndeterminate aria-label="Loading" />`}
/>

### Duration

Use the `duration` prop to indicate an approximate duration of an indeterminate task. Once the duration times out, the progress bar will start an indeterminate animation.

<ComponentPreview
  name="progress-bar/demos/duration"
  preview={`<ProgressBar duration="30s" />`}
/>

## Composition

If you need to customize things further, you can drop down to the composition level.

<ComponentPreview
  name="progress-bar/demos/composition"
  preview={`<ProgressBarRoot value={50} className="flex-row items-center gap-4">
    <Label>Progress</Label>
    <ProgressBarIndicator />
    <ProgressBarValueLabel />
  </ProgressBarRoot>`}
/>

## API Reference

| Prop              | Type                                                                                                     | Default              | Description                                                                                                 |
| ----------------- | -------------------------------------------------------------------------------------------------------- | -------------------- | ----------------------------------------------------------------------------------------------------------- |
| `variant`         | `"primary" \| "primary" \| "danger" \| "success" \| "warning"`                                           | `"default"`          | The visual style of the progress indicator.                                                                 |
| `size`            | `"sm" \| "md" \| "lg"`                                                                                   | `"md"`               | The size of the progress indicator                                                                          |
| `isIndeterminate` | `boolean`                                                                                                | -                    | Whether presentation is indeterminate when progress isn't known.                                            |
| `duration`        | `` `${number}s` \| `${number}ms` ``                                                                      | `'0s'`               | The estimated duration of an indeterminate progress.                                                        |
| `formatOptions`   | `Intl.NumberFormatOptions`                                                                               | `{style: 'percent'}` | The display format of the value label.                                                                      |
| `valueLabel`      | `ReactNode`                                                                                              | -                    | The content to display as the value's label (e.g. 1 of 4).                                                  |
| `showValueLabel`  | `boolean`                                                                                                | `false`              | Whether the value's label is displayed.                                                                     |
| `value`           | `number`                                                                                                 | `0`                  | The current value (controlled).                                                                             |
| `minValue`        | `number`                                                                                                 | `0`                  | The smallest value allowed for the input.                                                                   |
| `maxValue`        | `number`                                                                                                 | `100`                | The largest value allowed for the input.                                                                    |
| `children`        | `ReactNode \| (values: ProgressBarRenderProps & {defaultChildren: ReactNode \| undefined}) => ReactNode` | -                    | The children of the component. A function may be provided to alter the children based on component state.   |
| `className`       | `string`                                                                                                 | -                    | The CSS className for the element.                                                                          |
| `style`           | `CSSProperties \| (values: ProgressBarRenderProps & {defaultStyle: CSSProperties}) => CSSProperties`     | -                    | The inline style for the element. A function may be provided to compute the style based on component state. |
